package com.wk.util;

import java.io.File;
import java.io.IOException;

import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;

public class VoiceTest {

    public static void main(String[] args) throws IOException, LineUnavailableException, UnsupportedAudioFileException {

        File file = new File("f:/yokivoice_1453634725188.wav");
        Clip clip = AudioSystem.getClip();
        AudioInputStream ais = AudioSystem.getAudioInputStream(file);
        clip.open(ais);
        System.out.println(clip.getMicrosecondLength() / 1000000D + " s");
        
        /*try {  
            
            //MP3File file = new MP3File("c:\\TDDOWNLOAD\\shuangjiegun.mp3");//1,2  
            MP3File file = new MP3File("f:\\112.wma");//1,lyrics  
            // MP3File file = new MP3File("/home/zhubin/Music/1.mp3");//1,lyrics  
            AbstractID3v2 id3v2 = file.getID3v2Tag();  
            
            ID3v1 id3v1 = file.getID3v1Tag();  
  
            if (id3v2 != null) {  
  
                System.out.println("id3v2");  
  
                System.out.println(id3v2.getAlbumTitle());//专辑名  
                System.out.println(id3v2.getSongTitle());//歌曲名  
                System.out.println(id3v2.getLeadArtist());//歌手  
  
            } else {  
                System.out.println("id3v1");  
  
                System.out.println(id3v1.getAlbumTitle());  
                System.out.println(id3v1.getSongTitle());  
                System.out.println(id3v1.getLeadArtist());  
  
            }  
  
            AbstractLyrics3 lrc3Tag = file.getLyrics3Tag();  
            if (lrc3Tag != null) {  
                String lyrics = lrc3Tag.getSongLyric();  
                System.out.println(lyrics);  
            }  
  
        } catch (IOException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        } catch (TagException e) {  
            // TODO Auto-generated catch block  
            e.printStackTrace();  
        }  
  
        System.out.println("over"); */
        
        

    }

}
